import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Student[] students = {
                new Student("231210400431", "王泳茜", 100.0),
                new Student("231210400430", "王雪妍", 95.0),
                new Student("231210400429", "王晓然", 98.0),
                new Student("231210400432", "杨靖晗", 96.0),
                new Student("231210400433", "赵佳悦", 97.0),
                new Student("231210400428", "李琳", 90.0),
                new Student("231210400401", "党子瑞", 99.0),
                new Student("231210400402", "董泰恒", 89.0),
                new Student("231210400403", "李佳奇", 89.0),
                new Student("231210400404", "刘昊宇", 86.0)
        };
        System.out.println("所有学生信息：");
        for (Student s : students) s.display();

        Student.sortById(students);
        System.out.println("\n按学号排序：");
        for (Student s : students) s.display();

        Student.sortByScore(students);
        System.out.println("\n按成绩排序：");
        for (Student s : students) s.display();
    }

}
class Student{
    private String id;
    private String name;
    private double score;

    public Student(String id, String name, double score) {
        this.id = id;
        this.name = name;
        this.score = score;
    }
    public void display(){
        System.out.println("ID:"+id+" Name:"+name+" Score:"+score);
    }
    public static void sortById(Student[] student) {
        for (int i = 0; i < student.length - 1; i++) {
            for (int j = 0; j < student.length - 1 - i; j++) {
                if (student[j].id.compareTo(student[j + 1].id) > 0) {
                    Student temp = student[j];
                    student[j] = student[j + 1];
                    student[j + 1] = temp;
                }
            }
        }
    }
    public static void sortByScore(Student[] students) {
        for (int i = 0; i < students.length - 1; i++) {
            for (int j = 0; j < students.length - 1 - i; j++) {
                if (students[j].score < students[j + 1].score) {
                    Student temp = students[j];
                    students[j] = students[j + 1];
                    students[j + 1] = temp;
                }
            }
        }
    }
}
